package com.greendragon.service.backend.impl; 

import java.util.List;

import com.greendragon.persistence.dao.ICommentDao;
import com.greendragon.persistence.domain.ArticalComment;
import com.greendragon.persistence.enmu.FetchOrderType;
import com.greendragon.service.backend.ICommentBackendService;

/** 
 * @author wulibin, exceptsky@gmail.com, 2011-11-7 下午04:37:39
 * 
 */
public class ArticalCommentBackendService extends BaseBackendService<ArticalComment> implements ICommentBackendService<ArticalComment> {
	private ICommentDao<ArticalComment> commentDao;

	@Override
	public long getCountOfUnVerified() {
		ArticalComment expComment = new ArticalComment();
		expComment.setVerified(false);
		expComment.setBlock(false);
		return commentDao.getCountByCondition(expComment);
	}

	@Override
	public long getCountOfVerified() {
		ArticalComment expComment = new ArticalComment();
		expComment.setVerified(true);
		expComment.setBlock(false);
		return commentDao.getCountByCondition(expComment);
	}

	@Override
	public long getCountOfLock() {
		ArticalComment expComment = new ArticalComment();
		expComment.setBlock(true);
		return commentDao.getCountByCondition(expComment);
	}

	@Override
	public List<ArticalComment> getUnVerified(int page) {
		ArticalComment expComment = new ArticalComment();
		expComment.setVerified(false);
		expComment.setBlock(false);
		return commentDao.getByCondition(expComment, page*pageLength, pageLength, FetchOrderType.CREATE_DESC);
	}

	@Override
	public List<ArticalComment> getVerified(int page) {
		ArticalComment expComment = new ArticalComment();
		expComment.setVerified(true);
		expComment.setBlock(false);
		return commentDao.getByCondition(expComment, page*pageLength, pageLength, FetchOrderType.CREATE_DESC);
	}

	public void setCommentDao(ICommentDao<ArticalComment> commentDao) {
		this.commentDao = commentDao;
		this.setDao(commentDao);
	}
}
 